<?php

namespace app\services;


use support\Cache;

class SmsService
{

    public static function sendSms($phone)
    {
        $send_time = Cache::get($phone.'sms_code_time');
        if (!empty($send_time)){
            return '请勿频繁发送';
        }
        $statusStr = array(
            "0" => "短信发送成功",
            "-1" => "参数不全",
            "-2" => "服务器空间不支持,请确认支持curl或者fsocket，联系您的空间商解决或者更换空间！",
            "30" => "密码错误",
            "40" => "账号不存在",
            "41" => "余额不足",
            "42" => "帐户已过期",
            "43" => "IP地址限制",
            "50" => "内容含有敏感词"
        );
//        $smsapi = "http://api.smsbao.com/";
//        $user = "17731053938"; //短信平台帐号
//        $pass = md5("fsc20020915"); //短信平台密码
//        $code = rand(1000,9999);
//        $time = 30; //验证码有效时间
//        $content="【云点软件】您的验证码是{$code}。有效期为{$time}分钟，请尽快验证";//要发送的短信内容
//        $sendurl = $smsapi."sms?u=".$user."&p=".$pass."&m=".$phone."&c=".urlencode($content);
//        $result =file_get_contents($sendurl) ;

        $result = 0;
        $code = 1234;


        if ($result==0){
            Cache::set($phone.'sms_code',$code,1800);
            Cache::set($phone.'sms_code_time',time(),60);
        }
        return $statusStr[$result];
    }

}